package com.jcp.baselibrary.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.jcp.baselibrary.R;


/**
 * LoadingDialog
 *
 * @Date 2017/1/22.
 */

public class LoadingDialog extends CustomDialog {


    private ProgressBar progressBar;
    private TextView load_msg;
    private String loadMessage;

    public static LoadingDialog newInstance() {
        LoadingDialog dialog = new LoadingDialog();
        return dialog;
    }


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View loadView = inflater.inflate(R.layout.layout_loading_dialog, container, false);
        progressBar = (ProgressBar) loadView.findViewById(R.id.progress_loading);
        load_msg = (TextView) loadView.findViewById(R.id.load_msg);
        return loadView;
    }

    public void setMessage(String message) {
        this.loadMessage = message;
    }

    @Override
    public void onResume() {
        super.onResume();
        if (load_msg != null){
            load_msg.setText(loadMessage);
        }
    }
}
